<?php
/**
 * 判断用户是否登录
 */
declare (strict_types = 1);

namespace app\admin\middleware;

class Checkuserlogin
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        if($request->controller() != 'Login' && $request->controller() != 'Swagger' && !session('adminUserInfo.uid')){
            //判定用户是否登录
            return redirect((string)url('Login/index'));
        }

        // 继续执行进入到控制器
        return $next($request);
    }
}
